﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ADial
{
    public class NANPAParser : ITelephoneNumberParser
    {
        public bool matches(string number)
        {
            PhoneNumber pnum = PhoneNumber.Parse(number, true);
            return pnum.IsNanpValid;
        }

        public string parse(string number)
        {
            if (number == null) return "";
            string parsedNumber = "";
            PhoneNumber pnum = PhoneNumber.Parse(number, true);
            if (pnum.IsNanpValid)
            {
                parsedNumber += pnum.NpaCode.ToString("000");
            }
            parsedNumber += pnum.NxxCode.ToString("000");
            parsedNumber += pnum.StationCode.ToString("0000");
            return parsedNumber;    
        }
    }
}
